<%@ include file="/en/jsp/static.jsp" %>

<%@ page import="linuxbox.poll.logic.*,linuxbox.util.*,linuxbox.common.*" %>
<%@ taglib uri="/linuxbox/common.tld" prefix="common" %>
<jsp:include page="/en/jsp/header.jsp" flush="true"/>

<script Language="JavaScript">
  function confirmDel(entry)
	{
	  return confirm("Are you sure to delete " + entry);
  }
</script>


<table width="100%" height=26 align=middle border=0 cellpadding=0 cellspacing=0 bgcolor="#f4f4f4" style="font-size:16px;color:#d05000">
<tr><td>
	  &nbsp;<img src="<%=imageDir%>/itemball.jpg" width=14 height=15 border=0 align="absmiddle">
	  <b><%=boxName%> - Poll Management</b>
</td></tr>
</table>
<br>


<table width="100%" border=0 cellpadding=0 cellspacing=0>
<tr><td>

<FORM action="<%=servletDir%>/BoxPollAction" method="POST">
  <input type="submit" name="SubmitEdit" value="Create a new Poll">

<%
  BoxPoll home = new BoxPoll();
  java.util.Iterator it = home.getMyPolls(curUserID);
  if ( it != null && it.hasNext())
  {
%>
  <TABLE cellSpacing=1 cellPadding=3 width="100%" border=0 bgColor=#dddddd>
    <TR>
      <TH bgColor= #b9daf5 colspan = 7>My Polls</TH>
    </TR>
    <TR>
      <TH bgColor=#f4f5e1>Vote/View</TH>
      <TH bgColor=#f4f5e1>Edit</TH>
      <TH bgColor=#f4f5e1>Conclude</TH>
      <TH bgColor=#f4f5e1>Delete</TH>
      <TH bgColor=#f4f5e1>Polling Ends</TH>
      <TH bgColor=#f4f5e1>Create Time</TH>
      <TH bgColor=#f4f5e1>Create By</TH>
    </TR>
    <common:Iteration name="entry" type="BoxPollEntry" group="<%=it%>">
      <TR>
        <TD bgColor=#eeeeee>
          <a href="<%=servletDir%>/BoxPollVoteAction?SubmitView=view&ID=<%=entry.getID()%>"><%=entry.getSubject()%></a>
        </TD>
        <TD  bgColor=#eeeeee align=center>
          <a href="<%=servletDir%>/BoxPollAction?SubmitEdit=edit&ID=<%=entry.getID()%>">Edit</a>
        </TD>
        <TD bgColor=#eeeeee align=center>
          <a href="<%=servletDir%>/BoxPollConcludeAction?SubmitView=view&ID=<%=entry.getID()%>">Conclude</a>
        </TD>
        <TD bgColor=#eeeeee align=center>
          <a href="<%=servletDir%>/BoxPollAction?SubmitDelete=delete&ID=<%=entry.getID()%>"
          Onclick='return confirmDel("<%=entry.getSubject()%>")'
          >Delete</a>
        </TD>
        <TD  bgColor=#eeeeee>
          <%=entry.getConcludeTimeString()%>
        </TD>
        <TD  bgColor=#eeeeee>
          <%=entry.getCreateTimeString()%>
        </TD>
        <TD  bgColor=#eeeeee>
          <%=entry.getCreatedBy()%>
        </TD>
      </TR>
    </common:Iteration>
  </TABLE>
<%
  }
%>
<%
  it = home.getOtherPolls(curUserID);
  if ( it != null && it.hasNext())
  {
%>
  <p>
  <TABLE cellSpacing=1 cellPadding=3 width="100%" border=0 bgColor=#dddddd>
    <TR>
      <TH bgColor= #b9daf5 colspan = 7>Other Polls</TH>
    </TR>
    <TR>
      <TH bgColor=#f4f5e1>Vote/View</TH>
      <TH bgColor=#f4f5e1>Edit</TH>
      <TH bgColor=#f4f5e1>Conclude</TH>
      <TH bgColor=#f4f5e1>Delete</TH>
      <TH bgColor=#f4f5e1>Polling Ends</TH>
      <TH bgColor=#f4f5e1>Create Time</TH>
      <TH bgColor=#f4f5e1>Create By</TH>
    </TR>
    <common:Iteration name="entry" type="linuxbox.poll.logic.BoxPollEntry" group="<%=it%>">
      <TR>
        <TD bgColor=#eeeeee>
          <a href="<%=servletDir%>/BoxPollVoteAction?SubmitView=view&ID=<%=entry.getID()%>"><%=entry.getSubject()%></a>
        </TD>
<%
//  if (check user access right)
//  {
%>
        <TD  bgColor=#eeeeee align=center>
          <a href="<%=servletDir%>/BoxPollAction?SubmitEdit=edit&ID=<%=entry.getID()%>">Edit</a>
        </TD>
        <TD bgColor=#eeeeee align=center>
          <a href="<%=servletDir%>/BoxPollConcludeAction?SubmitView=view&ID=<%=entry.getID()%>">Conclude</a>
        </TD>
        <TD bgColor=#eeeeee align=center>
          <a href="<%=servletDir%>/BoxPollAction?SubmitDelete=delete&ID=<%=entry.getID()%>"
          Onclick='return confirmDel("<%=entry.getSubject()%>")'
          >Delete</a>
        </TD>
        <TD  bgColor=#eeeeee>
          <%=entry.getConcludeTimeString()%>
        </TD>
        <TD  bgColor=#eeeeee>
          <%=entry.getCreateTimeString()%>
        </TD>
        <TD  bgColor=#eeeeee>
          <%=entry.getCreatedBy()%>
        </TD>
      </TR>
    </common:Iteration>
  </TABLE>
<%
  }
  it = home.getClosedPolls(curUserID);
  if ( it != null && it.hasNext())
  {
%>
  <p>
  <TABLE cellSpacing=1 cellPadding=3 width="100%" border=0 bgColor=#dddddd>
    <TR>
      <TH bgColor= #b9daf5 colspan = 5>Closed Polls</TH>
    </TR>
    <TR>
      <TH bgColor=#f4f5e1>Vote/View</TH>
      <TH bgColor=#f4f5e1>Delete</TH>
      <TH bgColor=#f4f5e1>Create Time</TH>
      <TH bgColor=#f4f5e1>Create By</TH>
    </TR>
    <common:Iteration name="entry" type="linuxbox.poll.logic.BoxPollEntry" group="<%=it%>">
      <TR>
        <TD bgColor=#eeeeee>
          <a href="<%=servletDir%>/BoxPollVoteAction?SubmitView=view&ID=<%=entry.getID()%>"><%=entry.getSubject()%></a>
        </TD>
<%
//  if (check user access right or created by myself
//  {
%>
        <TD bgColor=#eeeeee align=center>
          <a href="<%=servletDir%>/BoxPollAction?SubmitDelete=delete&ID=<%=entry.getID()%>"
          Onclick='return confirmDel("<%=entry.getSubject()%>")'
          >Delete</a>
        </TD>
        <TD  bgColor=#eeeeee>
          <%=entry.getCreateTimeString()%>
        </TD>
        <TD  bgColor=#eeeeee>
          <%=entry.getCreatedBy()%>
        </TD>
      </TR>
    </common:Iteration>
  </TABLE>
<%
  }
%>
</FORM>
</td></tr>
</table>
<jsp:include page="/en/jsp/footer.jsp" flush="true"/>
